package com.pcbly.web.persistence.mail;


import java.util.List;

import com.pcbly.web.bean.mail.UserMailBean;
import com.pcbly.web.persistence.HibernateBaseDao;

public class UserMailHibernateDao extends HibernateBaseDao<UserMailBean> implements UserMailDao {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2509110579000483286L;
	protected Class<UserMailBean> getEntityClass() {
		return UserMailBean.class;
	}
	public UserMailHibernateDao(){
		super();
	}
	@Override
	public List<UserMailBean> getUserMailBeans() throws Exception {
		// TODO Auto-generated method stub
		return super.getAll(entityClass);
	}
	@Override
	public UserMailBean getUserMailBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return super.get(entityClass, id);
	}
	@Override
	public void addUserMailBean(UserMailBean userMailBean) throws Exception {
		// TODO Auto-generated method stub
		
		getHibernateTemplate().save(userMailBean);
		
	}
	@Override
	public UserMailBean getMainUserMailBeanByFlag(String flag) throws Exception {
		// TODO Auto-generated method stub
		String sql="select * from t_user_mailbox where MAINMAIL='"+flag+"'";
		return (UserMailBean)getSession().createSQLQuery(sql).addEntity(UserMailBean.class).uniqueResult();
	}
}
